import { baseRequestClient } from './request';

export interface AdItem {
  id: string;
  name: string;
  description: string;
  image: string[];
}

export interface AdListRes {
  code: number;
  data: AdItem[];
  message: string;
  status: boolean;
  success: boolean;
  timestamp: number;
}

/**
 * 获取广告位列表（GET /ad/list）
 */
export async function getAdList() {
  const res = await baseRequestClient.get<AdListRes>('/ad/list');
  return res?.data;
}

/** 新增广告位入参 */
export interface AddAdPayload {
  name: string;
  description: string;
  image: string[];
}

/**
 * 新增广告位（POST /ad/add）
 */
export async function addAd(payload: AddAdPayload) {
  const res = await baseRequestClient.post('/ad/add', payload);
  return res?.data;
}

/** 更新广告位入参 */
export interface UpdateAdPayload extends AddAdPayload {
  id: string;
}

/**
 * 更新广告位（POST /ad/update）
 */
export async function updateAd(payload: UpdateAdPayload) {
  const res = await baseRequestClient.post('/ad/update', payload);
  return res?.data;
}

/**
 * 删除广告位（DELETE /ad/{id}）
 */
export async function deleteAd(id: string) {
  const res = await baseRequestClient.delete(`/ad/${id}`);
  return res?.data;
}